#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
#define MAX_N 1000005
char st[MAX_N];
int next[MAX_N];

int main(){
    //freopen("1961.txt","r",stdin);
    int n,ncase = 0;
    while (scanf("%d",&n)!=EOF && n){
        ncase ++;
        scanf("%s",st);
        next[0] = -1;
        int t = -1;
        for (int i = 1 ; i < n ; i++){
            while (t!=-1 && st[t+1]!=st[i]) t=next[t];
            if (st[t+1]==st[i])
                t++;

            next[i] = t;
        }

        printf("Test case #%d\n",ncase);
        for (int i = 0 ; i < n ; i++) {
            if (next[i]!=-1 && (i+1) % (i-next[i]) == 0 &&(i+1) / (i-next[i])>1){
        //        cout <<"::"<<i<<" "<< next[i]<<endl;
                printf("%d %d\n",i+1,(i+1) / (i-next[i]) );
            }
        }
        printf("\n");
    }
    return 0;
}
